package com.dingwei.superiordiary.mvp.presenter;

import com.dingwei.superiordiary.base.MyBaseBean;
import com.dingwei.superiordiary.bean.FailsBean;
import com.dingwei.superiordiary.bean.SetStateBean;
import com.dingwei.superiordiary.custom.myCallback;
import com.dingwei.superiordiary.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class OtherSetPresenter extends basePresenter {

    private Contract.OtherView otherView;

    public OtherSetPresenter(Contract.OtherView view) {
        super(view);
        this.otherView = view;
    }


    public void initData() {
        RequestParams rp = new RequestParams(URLS.HOST + URLS.getSetState);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        x.http().post(rp, new myCallback(BaseActivity.context, SetStateBean.class, rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                SetStateBean bean = (SetStateBean) baseBean;
                otherView.setData(bean);
            }

            @Override
            public void fail(FailsBean baseBean, String result) {
            }
        });
    }

    public void settingUploadImg( String state) {
        RequestParams rp = new RequestParams(URLS.HOST+URLS.settingUploadImg);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        rp.addBodyParameter("state",state);
        x.http().post(rp, new myCallback(BaseActivity.context, MyBaseBean.class, rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                otherView.settingUploadImgSuccess();
            }

            @Override
            public void fail(FailsBean baseBean, String result) {
            }
        });

    }
}
